home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / util / rexx / FWCalendar.lha / FWCalendar / FWCalendar.rexx < prev   
Encoding:
OS/2 REXX Batch file  |  1998-09-30  |  18.5 KB  |  592 lines

  1. /*
  2.    Calendar Macro
  3.    Creates calendars on FinalWriter4 (SoftWood)
  4.    Written by Ronald Goertz
  5.    based on a program by Andrew McCardie
  6.    $VER: Calendar v2.15 (26 Sep 98)
  7. */
  8.  
  9. OPTIONS RESULTS
  10. address FINALW.1
  11. parse arg opt
  12.  
  13. if exists('LIBS:rexxtricks.library') then do
  14.   call addlib('rexxtricks.library', 0, -30, 0)
  15.   RexxTricks = 1
  16. end
  17. call addlib('rexxreqtools.library', 0, -30, 0)
  18.  
  19. ClearDoc
  20. if result == 0 then exit
  21. GetDocItemPrefs Decimal; DecimalFormat = result
  22. DocItemPrefs Decimal Period
  23. PageSetup ORIENT Wide
  24.  
  25. call SetVariables
  26.  
  27. CalType = rtezrequest('Monthly calendar or Whole-year summary?','Monthly|Whole Year|Cancel',,'rt_reqpos=reqpos_centerscr')
  28. if CalType == 0 then exit
  29.  
  30. if CalType == 2 then do
  31.   Year = SUBSTR(DATE('S'),1,4)
  32.   EnteredYear = rtgetstring(Year, 'Enter year:', 'Year Select', 'OK|Cancel', 'rt_reqpos=reqpos_centerscr', 'UserChoice')
  33.   if UserChoice == 0 | EnteredYear == "" then do
  34.     if upper(DecimalFormat) = 'COMMA' then DocItemPrefs Decimal Comma
  35.     Exit 10
  36.   end
  37.  
  38.   View 20
  39.   TextBlockTypePrefs SIZE FYMiniCalFSize COLOR BlackName
  40.   BoxPrefs LINEWT Hairline LINECOLOR BlackName FILL Transparent
  41.   DrawTextBlock 1 1 1 "1"; ID = RESULT
  42.   Redraw
  43.   GetObjectCoords ID; parse var RESULT . . . WidthOf1 .
  44.   DeleteObject ID
  45.  
  46.   Year = EnteredYear
  47.   CalTop = TopMargin
  48.   do r = 0 to 3
  49.     TopMargin = CalTop + r * (7*FYMiniCalFontHeight + MiniCalVSpacing)
  50.     do c = 0 to 2
  51.       Month = r * 3 + c + 1
  52.       Mn = right(Month, 2, '0')
  53.       TempDate = Year''Mn'01'
  54.       if (Year//4 == 0 & Year//100 > 0) | Year//400 == 0 Then MonthLength.2 = 29
  55.       interpret "StartDate = Day."Date('W', TempDate, 'S')
  56.       call DrawMiniCal(0, FYMiniCalWidth, FYMiniCalFontHeight)
  57.     end
  58.   end
  59.   selectobject
  60.   view 75
  61.   if upper(DecimalFormat) = 'COMMA' then DocItemPrefs Decimal Comma
  62.   exit
  63. end
  64.  
  65. if RexxTricks == 1 then do
  66.   CalMonth = getenv('CalMonth')
  67.   if CalMonth == '' then CalMonth = ThisMonth
  68.   else do
  69.     CalMonth = CalMonth + 1
  70.     if CalMonth = 13 then CalMonth = 1
  71.   end
  72. end
  73. else CalMonth = ThisMonth
  74.  
  75. MonthName = rtgetstring(Month.CalMonth, 'Enter month:', 'Month Select', 'OK|Cancel', 'rt_reqpos=reqpos_centerscr', 'UserChoice')
  76. Month = ConvertMonth(MonthName)
  77. if UserChoice == 0 | MonthName == "" | Month = 0 then do
  78.   if upper(DecimalFormat) = 'COMMA' then DocItemPrefs Decimal Comma
  79.   call rtezrequest('Month name not recognized.',,,'rt_reqpos=reqpos_centerscr')
  80.   Exit 10
  81. end
  82. Mn = right(Month, 2, '0')
  83. PrevMonth = Month - 1; if PrevMonth = 0 then PrevMonth = 12
  84. if RexxTricks == 1 then call setenv('CalMonth', Month)
  85.  
  86. Year = SUBSTR(DATE('S'),1,4)
  87. if Month < ThisMonth then Year = Year + 1
  88.  
  89. EnteredYear = rtgetstring(Year, 'Enter year:', 'Year Select', 'OK|Cancel', 'rt_reqpos=reqpos_centerscr', 'UserChoice')
  90. if UserChoice == 0 | EnteredYear = "" then do
  91.   if upper(DecimalFormat) = 'COMMA' then DocItemPrefs Decimal Comma
  92.   Exit 10
  93. end
  94.  
  95. call SetHighLights
  96.  
  97. /* Finally, the program */
  98. View 20
  99. Year = EnteredYear
  100. TempDate = Year''Mn'01'
  101.  
  102. if (Year//4 == 0 & Year//100 > 0) | Year//400 == 0 Then MonthLength.2 = 29
  103.  
  104. interpret "StartDate = Day."Date('W', TempDate, 'S')
  105.  
  106. TextBlockTypePrefs SIZE 4 COLOR WhiteName
  107. DrawTextBlock 1 0 0 TempDate /* Object ID == 2, only required for AddEvent macro, MUST be drawn first  */
  108. DrawTextBlock 1 0 0 Margins  /* Object ID == 3, only required for AddEvent macro, MUST be drawn second */
  109.  
  110. /* Draw dates and optional highlights */
  111. Day = - StartDate
  112. LineTop.    = CalTop
  113. LineBottom. = CalTop + BoxHeight*5
  114. LineLeft.   = LeftMargin
  115. LineRight.  = CalRight
  116.  
  117. TextBlockTypePrefs WIDTH DateFWidth FONT DateFont
  118. Do i = 0 to 5
  119.   if i = 5 then do
  120.     BoxTop = CalTop + BoxHeight*4.5
  121.     BHeight = BoxHeight/2
  122.   end
  123.   else do
  124.     BoxTop  = CalTop + BoxHeight*i
  125.     BHeight = BoxHeight
  126.   end
  127.                  
  128.   Do j = 0 to 6
  129.     Day = Day + 1
  130.     BoxLeft = LeftMargin + BoxWidth * j
  131.     If (Day < 1) | (Day > MonthLength.Month) then do
  132.       if Day < 1 then do
  133.         PrintDay = MonthLength.PrevMonth + Day
  134.         LineTop.j = CalTop + BoxHeight
  135.         LineLeft.0 = LeftMargin + BoxWidth * (j + 1)
  136.       end
  137.       else do
  138.         PrintDay = Day - MonthLength.Month
  139.         interpret "LineBottom."j+1" = "CalTop + BoxHeight*4
  140.         CalRow = i + 1
  141.         if LineRight.CalRow == CalRight then LineRight.CalRow = LeftMargin + BoxWidth * j
  142.       end
  143.       if Extended then Do
  144.         TextBlockTypePrefs SIZE DateFSize COLOR ExtendedColor
  145.         DrawTextBlock 1 (BoxLeft + DateOffset) (BoxTop + DateDown) PrintDay
  146.       End
  147.     End
  148.     else do
  149.       if i = 5 then DrawLine 1 BoxLeft BoxTop (BoxLeft + BoxWidth) BoxTop
  150.       if (j = 0 | j = 6) & (symbol('WeekendColor') == 'VAR') then do
  151.         BoxPrefs LINEWT None FILL Solid FILLCOLOR WeekendColor
  152.         DrawBox 1 BoxLeft BoxTop BoxWidth BHeight
  153.       end
  154.       if symbol('Highlight.Month.Day') == 'VAR' then do
  155.         if right(Highlight.Month.Day, 1) == '#' then do
  156.           TextBlockTypePrefs SIZE HighlightFSize WIDTH HighlightFWidth COLOR HighlightFColorB
  157.           if symbol('HighlightColorB') == 'VAR' then do
  158.             BoxPrefs LINEWT None FILL Solid FILLCOLOR HighlightColorB
  159.             DrawBox 1 BoxLeft BoxTop BoxWidth BHeight
  160.           end
  161.         end
  162.         else do
  163.           TextBlockTypePrefs SIZE HighlightFSize WIDTH HighlightFWidth COLOR HighlightFColorNB
  164.           if symbol('HighlightColorNB') == 'VAR' then do
  165.             BoxPrefs LINEWT None FILL Solid FILLCOLOR HighlightColorNB
  166.             DrawBox 1 BoxLeft BoxTop BoxWidth BHeight
  167.           end
  168.         end
  169.         TextLeft   = (BoxLeft + DateOffset) + HighlightOffset
  170.         TextBottom = (BoxTop + DateDown - (DateFontHeight - HighlightFontHeight)/2)
  171.         DrawTextBlock 1 TextLeft TextBottom compress(Highlight.Month.Day,'#')
  172.       End
  173.       else TextBlockTypePrefs COLOR DateFColor
  174.       TextBlockTypePrefs SIZE DateFSize
  175.       DrawTextBlock 1 (BoxLeft + DateOffset) (BoxTop + DateDown) Day
  176.     End
  177.     if (i = 5) & (Day = MonthLength.Month) then leave i
  178.   End
  179.   if Day >= MonthLength.Month then leave
  180. End
  181. LowRow = i
  182. if LowRow = 3 then LineBottom. = CalTop + BoxHeight*4
  183.  
  184. /* Draw vertical grid */
  185. do i = 0 to 7
  186.   LeftEdge = LeftMargin + BoxWidth*i
  187.   if Extended then do
  188.     LinePrefs LINECOLOR ExtendedColor
  189.     if LineTop.i > CalTop then DrawLine 1 LeftEdge CalTop LeftEdge LineTop.i
  190.     if LineBottom.i < LineBottom.8 then DrawLine 1 LeftEdge LineBottom.i LeftEdge LineBottom.8
  191.   end
  192.   LinePrefs LINECOLOR GridColor
  193.   DrawLine 1 LeftEdge LineTop.i LeftEdge LineBottom.i
  194. end
  195.  
  196. /* Draw horizontal grid */
  197. do i = 0 to min(LowRow + 1, 5)
  198.   TopEdge = CalTop + BoxHeight * i
  199.   if Extended then do
  200.     LinePrefs LINECOLOR ExtendedColor
  201.     if LineLeft.i > LeftMargin then DrawLine 1 LeftMargin TopEdge LineLeft.i TopEdge
  202.     if LineRight.i < CalRight then DrawLine 1 LineRight.i TopEdge CalRight TopEdge
  203.   end
  204.   LinePrefs LINECOLOR GridColor
  205.   DrawLine 1 LineLeft.i TopEdge LineRight.i TopEdge
  206. end
  207.  
  208. /* Create month/year header  */
  209. TextBlockTypePrefs SIZE MonthFSize WIDTH MonthFWidth COLOR MonthFColor FONT MonthFont
  210. DrawTextBlock 1 LeftMargin (TopMargin + (TextArea + MonthFontHeight)/3) upper(Month.Month" "Year); Month_obj = RESULT
  211.  
  212. /* Create weekday titles */
  213. TextBlockTypePrefs SIZE WeekdayFSize WIDTH WeekdayFWidth COLOR WeekdayFColor FONT WeekdayFont
  214. Do i = 0 to 6
  215.   DrawTextBlock 1 1 1 upper(Day.i); text_obj.i = RESULT
  216. End
  217.  
  218. Redraw
  219.  
  220. /* Position month/year header */
  221. GetObjectCoords Month_obj; Parse Var result . . TextBottom TextWidth TextHeight
  222. TextLeft = (LeftMargin + (PageWidth - TextWidth)/2)
  223. SetObjectCoords Month_obj 1 TextLeft TextBottom TextWidth TextHeight
  224.     
  225. /* Position weekday titles */
  226. TextBottom = CalTop - WeekdayFontHeight * .45
  227. Do i = 0 to 6
  228.   GetObjectCoords text_obj.i; Parse Var result . . . TextWidth TextHeight
  229.   BoxCenter = (LeftMargin + (i * BoxWidth) + BoxWidth/2)
  230.   TextLeft = (BoxCenter - TextWidth/2)
  231.   SetObjectCoords text_obj.i 1 TextLeft TextBottom TextWidth TextHeight
  232. End
  233.  
  234. if DoMiniCals = 1 then do
  235.   BoxPrefs LINEWT None FILL Solid FILLCOLOR HighlightColorNB
  236.   TextBlockTypePrefs SIZE MiniCalFSize COLOR MiniCalFColor FONT DateFont
  237.   BoxPrefs LINEWT Hairline LINECOLOR MiniCalBColor
  238.   if symbol('MiniCalColor') == 'VAR' then BoxPrefs FILL Solid FILLCOLOR MiniCalColor
  239.   else BoxPrefs FILL Transparent
  240.   DrawTextBlock 1 1 1 "1"; ID = RESULT
  241.   Redraw
  242.   GetObjectCoords ID; parse var RESULT . . . WidthOf1 .
  243.   DeleteObject ID
  244.  
  245.   call DrawMiniCal(-1, MiniCalWidth, MiniCalFontHeight)
  246.   call DrawMiniCal(+1, MiniCalWidth, MiniCalFontHeight)
  247. end
  248.  
  249. SelectObject
  250. View 75
  251.  
  252. if upper(DecimalFormat) = 'COMMA' then DocItemPrefs Decimal Comma
  253. exit
  254.  
  255. /*******  ConvertMonth Subroutine  ***********/
  256. ConvertMonth: PROCEDURE EXPOSE Month. AbbrMonth.
  257.   parse arg Month
  258.   MonthNumber = 0
  259.   if Datatype(Month) == upper('char') then
  260.     do i = 1 to 12
  261.       If upper(Month) == upper(Month.i) Then do; MonthNumber = i; leave; end
  262.       If upper(Month) == upper(AbbrMonth.i) Then do; MonthNumber = i; leave; end
  263.     end
  264.   else MonthNumber = Month
  265.   if MonthNumber < 1 | MonthNumber > 12 then MonthNumber = 0
  266.   return MonthNumber
  267.  
  268. /*******  SetHighlights Subroutine  ***********/
  269. SetHighlights:
  270. say "Setting highlights for "mn year
  271.   if exists(Pragma(D)'/FWMacros/FWCalendar.data') then do
  272.     call open(DataFile, Pragma(D)'/FWMacros/FWCalendar.data')
  273.       call seek(DataFile, HighlightStart, B)
  274.       do until eof(DataFile)
  275.         Ln = ReadLn(DataFile)
  276.         if left(Ln, 2) == Mn then interpret substr(Ln, 3)
  277.       end
  278.     call close(DataFile)
  279.   end
  280. return
  281.  
  282. /*******  CalculateDate Subroutine  ***********/
  283. CalculateDate:
  284. /* Month    is the month in which the highlight occurs                        */
  285. /* HighDate is the highest (numerical) date on which the highlight will occur */
  286. /* HighDay  is the weekday on which HighDate will occur                       */
  287. /* Event    is the highlight text                                             */
  288. parse arg GD_Month, GD_HighDay, GD_HighDate, GD_Event
  289.  
  290. interpret 'GD_HighDay = Day.'GD_HighDay
  291. interpret 'GD_First = Day.'Date(W, Year''right(GD_Month, 2, '0')'01', S)
  292.  
  293. GD_Day = GD_HighDate + (GD_HighDay - GD_First)
  294. if GD_First < GD_HighDay then GD_Day = GD_Day - 7
  295. Highlight.GD_Month.GD_Day = GD_Event
  296. return 0
  297.  
  298. /*******  DrawMiniCal Subroutine  ***********/
  299. DrawMiniCal:
  300.   parse arg MiniDirection, CalWidth, FHeight
  301.  
  302.   BoxCount = 0
  303.   MiniMonth = Month + MiniDirection
  304.   if MiniMonth == 0 | MiniMonth == 13 then do
  305.     MiniMonth = abs(MiniMonth - 12)
  306.     Year = EnteredYear + MiniDirection
  307.   end
  308.   Mn = right(MiniMonth, 2, '0')
  309.   call SetHighlights
  310.  
  311.   if MiniDirection < 0 then do
  312.     StartColumn = StartDate - MonthLength.MiniMonth//7
  313.     If StartColumn < 0 then StartColumn = StartColumn + 7
  314.     MiniCalLeft = LeftMargin + CalWidth/28
  315.   end
  316.   else if MiniDirection > 0 then do
  317.     StartColumn = StartDate + MonthLength.Month//7
  318.     If StartColumn > 6 then StartColumn = StartColumn - 7
  319.     MiniCalLeft = FullWidth - RightMargin - CalWidth
  320.   end
  321.   else do
  322.     StartColumn = StartDate
  323.     MiniCalLeft = LeftMargin + c * (CalWidth + MiniCalHSpacing)
  324.   end
  325.  
  326.   DrawTextBlock 1 1 (TopMargin + FHeight) Month.MiniMonth" "Year; ID.0 = RESULT
  327.   Redraw
  328.   GetObjectCoords ID.0; Parse var RESULT . . Top CurrentWidth Height
  329.   SetObjectCoords ID.0 1 (MiniCalLeft - CalWidth/28+ (CalWidth - CurrentWidth)/2) Top CurrentWidth Height
  330.   Column = StartColumn
  331.   Day = 0
  332.   Row = 2
  333.   Do Until Day = MonthLength.MiniMonth
  334.     Day = Day + 1
  335.  
  336.     if symbol('Highlight.MiniMonth.Day') == 'VAR' Then TextBlockTypePrefs FONT DateFontBold
  337.     else TextBlockTypePrefs FONT DateFont
  338.  
  339.     If Day < 10 then Do
  340.       DrawTextBlock 1 (MiniCalLeft+Column*CalWidth/7 + WidthOf1) (TopMargin + Row*FHeight) Day; ID.Day = RESULT
  341.     End
  342.     else Do
  343.       DrawTextBlock 1 (MiniCalLeft+Column*CalWidth/7) (TopMargin + Row*FHeight) Day; ID.Day = RESULT
  344.     End
  345.     if right(Highlight.MiniMonth.Day, 1) == '#' then do
  346.       BoxCount = BoxCount + 1
  347.       GetObjectCoords ID.Day; parse var result . Left Top CurrentWidth Height
  348.       DrawBox 1 Left (Top - .8 * Height) CurrentWidth Height; BoxID.BoxCount = result
  349.       ObjectToBack
  350.     end
  351.     Column = Column + 1
  352.     if Column == 7 then Do
  353.       Column = 0
  354.       Row = Row + 1
  355.     End
  356.   End
  357.   Rows = trunc((StartColumn + MonthLength.MiniMonth)/7) + 1.5
  358.   if (StartColumn + MonthLength.MiniMonth)//7 > 0 then Rows = Rows + 1
  359.   If CalType == 2 then Rows = 7.5
  360.   DrawBox 1 (MiniCalLeft - CalWidth/28) TopMargin CalWidth (Rows*FHeight)
  361.   ObjectToBack
  362.   Redraw
  363.   do i = 0 to MonthLength.MiniMonth; SelectObject ID.i MULTIPLE; End
  364.   do i = 1 to BoxCount; SelectObject BoxID.i MULTIPLE; End
  365.   Group
  366.   TextBlockTypePrefs FONT DateFont
  367. return
  368.  
  369. /*******  SetVariable Subroutine  ***********/
  370. SetVariables:
  371.   GetPageSetup Width Height Top Bottom Left Right
  372.   parse var result FullWidth FullHeight TopMargin BottomMargin LeftMargin RightMargin
  373.  
  374.   WhiteName =      'White'
  375.   BlackName =      'Black'
  376.  
  377.   if exists(Pragma(D)'/FWMacros/FWCalendar.data') then do
  378.     call open(DataFile, Pragma(D)'/FWMacros/FWCalendar.data')
  379.       VarCount = 0
  380.       do until eof(DataFile)
  381.         Ln = ReadLn(DataFile)
  382.         if (upper(word(Ln, 1)) == 'WHITENAME') | (upper(word(Ln, 1)) == 'BLACKNAME') then do
  383.           interpret Ln
  384.           VarCount = VarCount + 1
  385.         end
  386.         if VarCount == 2 then leave
  387.       end
  388.     call close(DataFile)
  389.   end
  390.  
  391.   DoMiniCals       = 1
  392. /*  MiniCalColor     = 'Red' */
  393.   MiniCalBColor    = BlackName
  394.   MiniCalFColor    = BlackName
  395.  
  396.   Extended         = 1
  397.   ExtendedColor    = 'Cyan'
  398.   GridColor        = BlackName
  399.  
  400. /*  WeekendColor     = 'Cyan' */
  401.  
  402.   MonthFont        = "FONTS:Nimbus-Q/Serif/Dragon"
  403.   MonthFSize       = 44
  404.   MonthFWidth      = 100
  405.   MonthFColor      = BlackName
  406.  
  407.   WeekdayFont      = "FONTS:Nimbus-Q/Serif/Dragon"
  408.   WeekdayFSize     = 22
  409.   WeekdayFWidth    = 100
  410.   WeekdayFColor    = BlackName
  411.  
  412.   DateFont         = "SoftSans"
  413.   DateFontBold     = "SoftSans_Bold"
  414.   DateFSize        = 10
  415.   DateFWidth       = 100
  416.   DateFColor       = BlackName
  417.  
  418.   HighlightFSize   = 8
  419.   HighlightFColorNB= BlackName
  420.   HighlightFColorB = BlackName
  421. /*  HighlightColorNB = WhiteName */
  422. /*  HighlightColorB  = WhiteName */
  423.  
  424.   MiniCalFSize     = 8
  425.   MiniCalHSpacing  = 0.05
  426.   MiniCalVSpacing  = 0.1
  427.  
  428.   Day.0 = 'Sunday'
  429.   Day.1 = 'Monday'
  430.   Day.2 = 'Tuesday'
  431.   Day.3 = 'Wednesday'
  432.   Day.4 = 'Thursday'
  433.   Day.5 = 'Friday'
  434.   Day.6 = 'Saturday'
  435.  
  436.   Month.1  = 'January'
  437.   Month.2  = 'February'
  438.   Month.3  = 'March'
  439.   Month.4  = 'April'
  440.   Month.5  = 'May'
  441.   Month.6  = 'June'
  442.   Month.7  = 'July'
  443.   Month.8  = 'August'
  444.   Month.9  = 'September'
  445.   Month.10 = 'October'
  446.   Month.11 = 'November'
  447.   Month.12 = 'December'
  448.  
  449.   AbbrMonth.1  = 'Jan'
  450.   AbbrMonth.2  = 'Feb'
  451.   AbbrMonth.3  = 'Mar'
  452.   AbbrMonth.4  = 'Apr'
  453.   AbbrMonth.5  = 'May'
  454.   AbbrMonth.6  = 'Jun'
  455.   AbbrMonth.7  = 'Jul'
  456.   AbbrMonth.8  = 'Aug'
  457.   AbbrMonth.9  = 'Sep'
  458.   AbbrMonth.10 = 'Oct'
  459.   AbbrMonth.11 = 'Nov'
  460.   AbbrMonth.12 = 'Dec'
  461.  
  462.   MonthLength.1    = 31
  463.   MonthLength.2    = 28
  464.   MonthLength.3    = 31
  465.   MonthLength.4    = 30
  466.   MonthLength.5    = 31
  467.   MonthLength.6    = 30
  468.   MonthLength.7    = 31
  469.   MonthLength.8    = 31
  470.   MonthLength.9    = 30
  471.   MonthLength.10   = 31
  472.   MonthLength.11   = 30
  473.   MonthLength.12   = 31
  474.  
  475.   Day.Sunday    = 0
  476.   Day.Monday    = 1
  477.   Day.Tuesday   = 2
  478.   Day.Wednesday = 3
  479.   Day.Thursday  = 4
  480.   Day.Friday    = 5
  481.   Day.Saturday  = 6
  482.  
  483.   if exists(Pragma(D)'/FWMacros/FWCalendar.data') then do
  484.     call open(DataFile, Pragma(D)'/FWMacros/FWCalendar.data')
  485.       do until eof(DataFile)
  486.         Ln = ReadLn(DataFile)
  487.         if left(Ln, 15) == '/* End Pass One' then do
  488.           HighlightStart = seek(DataFile, 0)
  489.           leave
  490.         end
  491.         interpret Ln
  492.       end
  493.     call close(DataFile)
  494.   end
  495.  
  496.   GetDisplayPrefs Measure; Units = result
  497.   select
  498.     when Units = 'Inches' then PointsPerUnit = 72
  499.     when Units = 'Metric' then PointsPerUnit = 28.34645669291
  500.     when Units = 'Pica' then   PointsPerUnit = 12
  501.   end
  502.  
  503.   MonthFontHeight     = MonthFSize / PointsPerUnit
  504.   WeekdayFontHeight   = WeekdayFSize / PointsPerUnit
  505.   DateFontHeight      = DateFSize / PointsPerUnit
  506.   HighlightFontHeight = HighlightFSize / PointsPerUnit
  507.   MiniCalFontHeight   = MiniCalFSize / PointsPerUnit
  508.  
  509.   PageWidth  = FullWidth - LeftMargin - RightMargin
  510.   PageHeight = FullHeight - TopMargin - BottomMargin
  511.   TextArea   = 2.1 * MonthFontHeight
  512.   BoxWidth   = PageWidth/7
  513.   BoxHeight  = (PageHeight-TextArea)/5
  514.   CalTop     = TopMargin + TextArea
  515.   CalRight   = LeftMargin + BoxWidth * 7
  516.  
  517.   Margins = TopMargin'|'BottomMargin'|'LeftMargin'|'RightMargin'|'TextArea
  518.  
  519.   DateDown        = DateFontHeight
  520.   DateOffset      = 3.6 / PointsPerUnit
  521.   HighlightOffset = 14.4 / PointsPerUnit
  522.   MiniCalWidth    = 108 / PointsPerUnit
  523.  
  524.   FYMiniCalWidth      = PageWidth/3
  525.   FYMiniCalFontHeight = PageHeight/31
  526.   FYMiniCalFSize      = trunc(FYMiniCalFontHeight * PointsPerUnit)
  527.  
  528.   ThisMonth = left(date('U'), 2) + 0
  529.   TextBlockPrefs TEXTFLOW None
  530.  
  531.   if TestMode = 1 then call TestSettings
  532. return
  533.  
  534. TestSettings:
  535.   ErrorCount = 0
  536.   ErrorString = ''
  537.  
  538.   FontVariable.1 = 'MonthFont';   Font.1 = MonthFont
  539.   FontVariable.2 = 'WeekdayFont'; Font.2 = WeekdayFont
  540.   FontVariable.3 = 'DateFont';    Font.3 = DateFont
  541.   FontVariable.4 = 'DateFontBold';Font.4 = DateFontBold
  542.   Do i = 1 to 4
  543.     Font Font.i
  544.     type i
  545.     status FontPath; CurrentFont = result
  546.     if NameOnly(Font.i) ~= NameOnly(CurrentFont) then do
  547.       ErrorCount = ErrorCount + 1
  548.       ErrorString = ErrorString||'0a'x||'   'FontVariable.i
  549.     end
  550.   end
  551.  
  552.   ColorName.1 = 'WhiteName';          Color.1 = WhiteName
  553.   ColorName.2 = 'BlackName';          Color.2 =  BlackName
  554.   ColorName.3 = 'MiniCalColor';       Color.3  = MiniCalColor
  555.   ColorName.4 = 'MiniCalBColor';      Color.4  = MiniCalBColor
  556.   ColorName.5 = 'MiniCalFColor';      Color.5  = MiniCalFColor
  557.   ColorName.6 = 'ExtendedColor';      Color.6  = ExtendedColor
  558.   ColorName.7 = 'GridColor';          Color.7  = GridColor
  559.   ColorName.8 = 'WeekendColor';       Color.8  = WeekendColor
  560.   ColorName.9 = 'MonthFColor';        Color.9  = MonthFColor
  561.   ColorName.10 = 'DateFColor';        Color.10 = DateFColor
  562.   ColorName.11 = 'HighlightFColorNB'; Color.11 = HighlightFColorNB
  563.   ColorName.12 = 'HighlightFColorB';  Color.12 = HighlightFColorB
  564.   ColorName.13 = 'HighlightColorNB';  Color.13 = HighlightColorNB
  565.   ColorName.14 = 'HighlightColorB';   Color.14 = HighlightColorB
  566.   do j = 1 to 14
  567.     if symbol(ColorName.j) == 'VAR' then do
  568.       FontColor Color.j
  569.       type i + j
  570.       status FontColor; CurrentColor = result
  571.       if CurrentColor ~= Color.j then do
  572.         ErrorCount = ErrorCount + 1
  573.         ErrorString = ErrorString||'0a'x||'   'ColorName.j
  574.       end
  575.     end
  576.   end
  577.  
  578.   SelectAll; Clear
  579.  
  580.   if ErrorCount ~= 0 then do
  581.     ErrorString = 'The following variable(s) are not properly defined:'||ErrorString
  582.     call rtezrequest(ErrorString)
  583.   end
  584. return
  585.  
  586. NameOnly:
  587.   parse arg fontname
  588.  
  589.   lastcolon = LastPos(':', fontname)
  590.   lastslash = lastpos('/', fontname)
  591.   return substr(fontname, max(lastcolon, lastslash) + 1)
  592.